'use strict'

const path = require('path')
const fs = require('fs')
const router = require('koa-router')()

module.exports = function (app) {

  router.get('/', async (ctx, next) => {
    const data = fs.readFileSync(path.join(__dirname, '../views/index.html'))

    ctx.type = 'text/html; charset=utf-8'
    ctx.body = data

  })
  router.use('/api', require('./hello').routes(), require('./hello').allowedMethods())
  router.use('/api/login', require('./login').routes(), require('./login').allowedMethods())
  router.use('/api/users', require('./users').routes(), require('./users').allowedMethods())
  router.use('/api/upload', require('./upload').routes(), require('./upload').allowedMethods())

  app.use(router.routes(), router.allowedMethods())

}